<?php
/**
 * tpAdmin [a web admin based ThinkPHP5]
 *
 * @author yuan1994 <tianpian0805@gmail.com>
 * @link http://tpadmin.yuan1994.com/
 * @copyright 2016 yuan1994 all rights reserved.
 * @license http://www.apache.org/licenses/LICENSE-2.0
 */

//------------------------
// 登录日志模型
//-------------------------

namespace app\common\model;

use think\Model;
use think\Db;
class Questype extends Model
{
	
	// 指定表名,不含前缀
    protected $name = 'questype';
    //获取题型列表
    //参数：查询条件数组
    //返回值：题型列表数组
    public function getQuestypeList($args = 1,$field = '*')
    {
        $arr=Db::name($this->name)->where('isdelete',0)->field($field)->where($args)->select();
        return $arr;
    }


	//获取题型列表
    //参数：查询条件数组
    //返回值：题型列表数组
    public function getQuesTypesById($args=1)
    {	if(empty($args)) return false;
		if(is_array($args)) $args = implode(',',$args);
		$arr=Db::name('questype')->where('isdelete',0)->where('id','in',$args)->select();
        return $arr;
    }
	
	//获取题型列表并转为以题型ID为KEY的数组
    //参数：查询条件数组
    //返回值：题型列表数组
	public function getQuestypeArray()
	{
		$res = $this->getQuestypeList();
		if(empty($res)) return;
		foreach($res as $val)
		{
			$result[$val['id']] = $val['type'];
		}
		
		return $result;
	}
	
	
}
